/*
* Copyright (c)  2017, ueboot.com
* All rights reserved.
* 2017-10-14 21:04:14
*/
package com.ueboot.weishop.service.activity;

import com.ueboot.weishop.entity.activity.ActivityAttrEntity;
import com.ueboot.weishop.entity.activity.ActivityEntity;
import com.ueboot.core.service.BaseService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Neel  on 2017-10-14 21:04:14.
 * @author yangkui
 * @since 2.0 by autocode
 */
public interface ActivityService extends BaseService<ActivityEntity> {
    /**
     * 根据类型查询不同的活动列表
     * @param pageable 分页数据
     * @param type 类型，参加模型类的定义
     * @return
     */
    Page<ActivityEntity> findByTypeOrderByStartTimeAsc(Pageable pageable, String type);

    /**
     * 保存活动信息，需要同时更新商品对应的活动信息
     * @param entity
     */
    void saveActivity(ActivityEntity entity,Long goodsId);


    void saveActivity(ActivityEntity entity, List<ActivityAttrEntity> attrs);

    void saveActivityGoods(ActivityEntity entity, Long[] goodsIds);

    /**
     * 删除活动时，需要同时更新商品对应的活动信息
     * @param id
     */
    void deleteActivity(Long id);


    /**
     * 清空缓存
     */
    void clearActivityCache();

    /**
     * 根据活动代码查询活动，默认会从缓存当中查询
     * @param sn 活动代码
     * @return
     */
    ActivityEntity findBySn(String sn);
    /**
     * 根据活动ID查询活动，默认会从缓存当中查询
     * @param id 数据库ID
     * @return
     */
    ActivityEntity findById(Long id);

    void updateActivityEntity(ActivityEntity act);

    /**
     * 监听redis失效接口，进行活动的库存回滚
     * @param redisMessage
     */
    void rollbackStock(String redisMessage);

    ActivityEntity findTopBySnAndTypeAndStatusOrderByFirstInsertDesc(String activitySN, String typeSecKill, String statusOpening);

    List<ActivityEntity> findByTypeAndDate(String type, String date);

    List<ActivityEntity> findByTypeOrderByStartTimeAsc(String type);
}
